package com.lxp.userms.service.impl;

import com.lxp.userms.entity.Comment;
import com.lxp.userms.mapper.CommentMapper;
import com.lxp.userms.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class CommentServiceImpl implements CommentService {

    @Autowired
    private CommentMapper commentMapper;

    @Override
    @Transactional
    public int addComment(Comment comment) {
        return commentMapper.insertComment(comment);
    }

    @Override
    public List<Comment> getCommentsByPostId(int postId) {
        return commentMapper.selectCommentsByPostId(postId);
    }


    public void deleteCommentsByPostId(int postId) {
        commentMapper.deleteCommentsByPostId(postId);
}
}